package com.enzoism.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;

/**
 * Created with IntelliJ IDEA.
 * User: enzoism
 * Date: 2019/9/4- 2:14
 */
@Api(value = "页面请求转跳到指定页面")
@Controller
public class PageController {

    @ApiOperation(value = "index页面转跳方法", notes = "INDEX页面转跳方法NOTE")
    @RequestMapping(value = "/index",method = RequestMethod.GET)
    public String index(HttpServletRequest request) {
        request.setAttribute("name", "index");
        return "index";
    }

    @ApiOperation(value = "hello页面转跳方法", notes = "HELLO页面转跳方法NOTE")
    @RequestMapping(value = "/hello",method = RequestMethod.GET)
    public String hello( @ApiParam(value = "name参数：用户名称" , required=true )  @RequestParam String name,
                         HttpServletRequest request) {
        request.setAttribute("name", name);
        return "index";
    }

    @RequestMapping(value = "/notLogin",method = RequestMethod.GET)
    public String notLogin(HttpServletRequest request) {
        request.setAttribute("name", "notLogin");
        return "nologin";
    }

    @RequestMapping(value = "/notRole",method = RequestMethod.GET)
    public String notRole(HttpServletRequest request) {
        request.setAttribute("name", "notRole");
        return "norole";
    }
}
